Software-defined networking (SDN) includes a control device and a forwarding device. The forwarding device may be a network device such as a router or a switch. The control device may be configured to control network traffic. The forwarding device is configured to perform forwarding processing on a received data packet. Further, the forwarding device may query a forwarding information base (FIB) according to a destination Internet Protocol (IP) address of the received data packet, and forward the data packet according to an outbound interface in a forwarding entry matching the destination IP address in the FIB. However, in some cases, a user expects to intervene in a data packet passing through the forwarding device, for example, to suppress a message that has a specific source IP address and that is for accessing a destination IP address, or discard corresponding data. In this case, a flow specification (Also referred to as FlowSpec) forwarding table that includes at least one flow specification may be set on the forwarding device. The flow specification may include a flow matching condition and an action performed on a matching flow. The flow matching condition may include a destination IP address, a source IP address, a destination port, and the like. The action may include discarding, redirection to a specific port, and the like. In this way, when receiving a data packet, the forwarding device may first query the flow specification forwarding table. If the flow specification forwarding table has a flow specification matching the data packet, the forwarding device may perform a corresponding action in the matching flow specification. Subsequently, if the data packet needs to be forwarded, the forwarding device may continue to query the FIB in order to determine an outbound interface for the data packet.
In other approaches, when a router carries relatively heavy loads because a relatively large quantity of flows pass through the forwarding device, the flows passing through the forwarding device may be adjusted to another path. Further, the control device may deliver a flow specification to the router. The flow specification instructs to redirect a next hop of a specific flow to another forwarding device. After receiving the flow specification delivered by the control device, the forwarding device may add the flow specification to a flow specification forwarding table of the forwarding device, and perform, according to the flow specification forwarding table, redirection processing on a flow that meets a condition.
However, the flow specification forwarding table usually has relatively small space. This limits a quantity of flows that can be adjusted by the forwarding device.